<template>
  <h1>练习-计算器</h1>
  <input type="number" placeholder="请输入数字1" v-model="a">
  <input type="number" placeholder="请输入数字2" v-model="b">
  <br>
  <button @click="num('+')">加</button>
  <button @click="num('-')">减</button>
  <button @click="num('*')">乘</button>
  <button @click="num('/')">除</button>
  <h3>运算结果:{{ result }}</h3>
</template>

<script setup>
import {ref} from "vue";

const result = ref('');
const a = ref('');
const b = ref('');
const num = (o) => {
  result.value = eval(a.value + o + b.value);
};

</script>

<style scoped>

</style>